package com.example.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class LoginPage extends AnyPage {
	
	@FindBy (id = "username")
	protected WebElement userNameField;
	
	@FindBy (name = "password")
	protected WebElement passwordField;
	
	@FindBy (name = "submit")
	protected WebElement loginButton;
	
	@FindBy (id = "loginform")
	protected WebElement loginForm;
	
	public boolean isOnThisPage() {
		return loginForm.isDisplayed();
		
	}
	public InternalPage loginAs(String username, String password) {
		userNameField.clear();
		userNameField.sendKeys(username);
		passwordField.clear();
		passwordField.sendKeys(password);
		loginButton.click();
		return MyPageFactory.getPage(driver, InternalPage.class);
	}
}
